//				var search=document.querySelector(".searching"),
//					term=search.querySelectorAll("div"),
//				function searching(){
//					j=0;
//					term.forEach(val=>{
//						val.className="";
//					})
//					while(j<term.length){
//						
//					}
//				}
//				function change(n){
//					term[n].className="active";
//					
//				}

function carousel(parent) {
	this.img = parent.getElementsByTagName("img");
	this.li = parent.getElementsByTagName("li");
	this.j = 0;
	this.timer = null;
}
carousel.prototype.init = function() {
	this.bind();
}
carousel.prototype.bind = function() {
	this.timeMake();

}
carousel.prototype.action = function(num, d) {
	if(num) {
		this.j += num;
		this.j == this.img.length - 1 && (this.j = 0);
		this.j == -1 && (this.j = this.img.length - 2);
	} else {
		console.log(this.j);
		this.j = d;
		console.log(this.j);

	}
	this.clear();
	this.img[this.j].className = "active";
	this.li[this.j].className = "active";
}
carousel.prototype.clear = function() {
	for(var i = 0; i < this.img.length - 1; i++) {
		this.img[i].className = "";
		this.li[i].className = "";
	}
}
carousel.prototype.timeMake = function() {
	var me = this;
	var timer = setInterval(function() {
		me.action(1);
	}, 2000)
}
var carousels1 = new carousel(carousel1);
carousels1.init();

var aside = document.querySelectorAll("aside")[0],
	overlay = document.querySelectorAll(".overlay")[0];
list_switch.onclick = function() {
	aside.style.display = "block";
}
aside.onclick = function() {
	var target = event.srcElement;
	if(target.parentNode.tagName == "BODY") {
		this.style.display = "none";
	}
}

var fs_title = document.querySelectorAll(".fs_title")[0],
	time = fs_title.getElementsByTagName("span")[0];

function setTime() {
	var now = new Date(),
		end = new Date();
	end.setHours(20);
	end.setMinutes(0);
	end.setSeconds(0);
	if(now.getHours() >= 20) {
		end.setDate(now.getDate() + 1);
	}
	var ms = (end - now) / 1000;
	var hour = parseInt(ms / 60 / 60);
	hour < 10 && (hour = "0" + hour);
	var min = parseInt(ms / 60 % 60);
	min < 10 && (min = "0" + min);
	var s = parseInt(ms % 60);
	s < 10 && (s = "0" + s);

	time.innerHTML = ` ${hour} : ${min} : ${s} `;
}

setTime();
timer = setInterval(() => {
	setTime();
}, 500)

var foot=document.querySelector("footer"),
	div=foot.getElementsByTagName("div"),
	span=document.getElementsByTagName("span")[0];
div[2].onclick=function(){
	location = "trolley.html";
}
span.onclick=function(){
	location = "login.html";
}
QQQ.onclick=function(){
	location = "login.html";
}
$(document).scroll(()=>{
	if($(window).scrollTop()>="800"){
		$(".guide").fadeIn(500);
	}else{
		$(".guide").fadeOut(300);
	}
})

$(".g_box:last-of-type").click(e=>{
	$('body,html').animate({
          scrollTop: 0
        },
        500);
})
$(".searching").click(()=>{
	$(location).attr('href', 'searching.html');
	$(window).attr('location','searching.html');
	$(location).prop('href', 'searching.html');
})

